package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class DelOperation implements IOPeration{
    @Override
    public void work(BookList bookList) {
        System.out.println("删除图书。。。");

        System.out.println("请输入你要删除的书的名称：");
        Scanner scanner = new Scanner(System.in);
        String bookName = scanner.next();
        int index = bookList.getBookId(bookName);
        if (index == -1) {
            System.out.println("查无此书");
        } else {
            Book[] books = bookList.getBook();
            bookList.deleBookById(index,books);
            System.out.println("删除成功！");
        }

    }
}
